/**
 * This is the class to implement interface UserService
 */
package cn.fanyamin.business;

import java.util.List;

import cn.fanyamin.dao.ModuleDao;
import cn.fanyamin.domain.Module;
import cn.fanyamin.domain.User;
import cn.fanyamin.util.collection.CollectionUtils;
import cn.fanyamin.util.email.EmailSender;


/**
 * 
 * @author walter.fan@gmail.com on 07/18/06
 */
@SuppressWarnings("serial")
public class UserServiceImpl extends CRUDService<Integer, User> implements
		UserService {
	private EmailSender sender = null;
	private ModuleDao moduleDao = null;

	/**
	 * @return the sender
	 */
	public EmailSender getSender() {
		return sender;
	}

	/**
	 * @param sender
	 *            the sender to set
	 */
	public void setSender(EmailSender sender) {
		this.sender = sender;
	}

	

	public void setModuleDao(ModuleDao moduleDao) {
		this.moduleDao = moduleDao;
	}

	public List<Module> getFavoriteModules(int userID) {
		return moduleDao.getFavoriteModules(userID);
	}

    public User getUser(String userName, String password) {
        User aUser = new User();
        aUser.setUserName(userName);
        aUser.setPassword(password);
        List<User> userList = myDao.find(aUser);
        if(CollectionUtils.isEmpty(userList)|| userList.size() > 1) {
            return null;
        } else {
            return userList.get(0);
        }
    }

    public Boolean checkToken(String token) {
        // TODO Auto-generated method stub
        return null;
    }

    public String createToken(String fromAddr) {
        // TODO Auto-generated method stub
        return null;
    }

}
